﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Qpm.Automap.Core.UI
{
    public partial class AddressForm : Form
    {
        public UnstructuredAddressType Address { get; set; }

        public AddressForm()
        {
            InitializeComponent();
        }

        private void AddressForm_Load(object sender, EventArgs e)
        {
            //Code commented out because it does not apply to the D07A schemas
            /*if (Address != null)
            {
                txt_CityId.Text = Address.CityID == null ? "" : Address.CityID.Value;
                txt_CityName.Text = Address.CityName == null ? "" : Address.CityName.Value;
                txt_CitySubDivisionName.Text = Address.CitySubDivisionName == null ? "" : Address.CitySubDivisionName.Value;
                txt_CountryId.Text = Address.CountryID == null ? "" : Address.CountryID.Value;
                txt_CountryName.Text = Address.CountryName == null ? "" : Address.CountryName.Value;
                txt_CountrySubdivisionId.Text = Address.CountrySubDivisionID == null ? "" : Address.CountrySubDivisionID.Value;
                txt_CountrySubdivisionName.Text = Address.CountrySubDivisionName == null ? "" : Address.CountrySubDivisionName[0].Value;
                txt_ID.Text = Address.ID == null ? "" : Address.ID.Value;
                txt_Line5.Text = Address.LineFive == null ? "" : Address.LineFive.Value;
                txt_line4.Text = Address.LineFour == null ? "" : Address.LineFour.Value;
                txt_Line1.Text = Address.LineOne == null ? "" : Address.LineOne.Value;
                txt_Line3.Text = Address.LineThree == null ? "" : Address.LineThree.Value;
                txt_Line2.Text = Address.LineTwo == null ? "" : Address.LineTwo.Value;
                txt_PostCode.Text = Address.PostcodeCode == null ? "" : Address.PostcodeCode.Value;
                txt_TypeCode.Text = Address.TypeCode == null ? "" : Address.TypeCode.Value;
            }*/
        }

        private void b_Cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void b_OK_Click(object sender, EventArgs e)
        {
            SetAddress();
            this.Close();
        }

        private void SetAddress()
        {
            //Code commented out because it does not apply to the D07A schemas
            /*Address = new UnstructuredAddressType();
            Address.CityID = new IDType(txt_CityId.Text);
            Address.CityName = new TextType(txt_CityName.Text);
            Address.CitySubDivisionName = new TextType(txt_CitySubDivisionName.Text);
            Address.CountryID = new IDType(txt_CountryId.Text);
            Address.CountryName = new TextType(txt_CountryName.Text);
            Address.CountrySubDivisionID = new IDType(txt_CountrySubdivisionId.Text);
            Address.CountrySubDivisionName = new TextType[1];
            Address.CountrySubDivisionName[0] = new TextType(txt_CountrySubdivisionName.Text);
            Address.ID = new IDType(txt_ID.Text);
            Address.LineFive = new TextType(txt_Line5.Text);
            Address.LineFour = new TextType(txt_line4.Text);
            Address.LineOne = new TextType(txt_Line1.Text);
            Address.LineThree = new TextType(txt_Line3.Text);
            Address.LineTwo = new TextType(txt_Line2.Text);
            Address.PostcodeCode = new CodeType();
            Address.PostcodeCode.Value = txt_PostCode.Text;
            Address.TypeCode = new AddressTypeCodeType();
            Address.TypeCode.Value = txt_TypeCode.Text;*/
        }
    }
}
